import { Info } from "@/api/user";

export interface DataInfo extends Info {
  /** 当前登陆用户的角色 */
  roles?: Array<string>;
}

export const sessionKey = "user-info";
export const TokenKey = "authorized-token";

/** 获取`token` */
export function getToken(): string {
  return localStorage.getItem("token");
}
// 设置token
export function setToken(token: string) {
  localStorage.setItem("token", token);
}

/** 删除`token`以及key值为`user-info`的session信息 */
export function removeToken() {
  localStorage.removeItem("token");
  localStorage.clear();
}

/** 格式化token（jwt格式） */
export const formatToken = (token: string): string => {
  return "Bearer " + token;
};
